package kr.co.bettersoft.carrotmemberstore.adapter;

import java.util.List;

import kr.co.bettersoft.carrotmemberstore.R;
import kr.co.bettersoft.carrotmemberstore.domain.CheckMileageMileage;

import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
//import android.widget.ImageView;
import android.widget.TextView;
public class ButtonAdapter2 extends BaseAdapter {
	private Context mContext;   
	public int cellHeight;
	public int cellWidth;
	public ButtonAdapter2(Context c) {  
		mContext = c;   
		cellHeight = getCellHeightDP();
		cellWidth = getCellWidthDP();
	}  
	public int getCount() {   
		return mThumbIds.length;   
	}   
	public Object getItem(int position) {    
		return null;  
	}   
	public long getItemId(int position) {  
		return 0;   
	}   
	// create a new ImageView for each item referenced by the Adapter   
	public View getView(int position, View convertView, ViewGroup parent) { 
		ImageView imageView;      
		if (convertView == null) {  
			// if it's not recycled, initialize some attributes   
			
			imageView = new ImageView(mContext);     
			imageView.setLayoutParams(new GridView.LayoutParams(cellWidth, cellHeight));   
			imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);   
			imageView.setPadding(1, 1, 1, 1);    
		} else {      
			imageView = (ImageView) convertView;      
		}       
		imageView.setImageResource(mThumbIds[position]);    
		return imageView;   
	}   
	// references to our images  
	private Integer[] mThumbIds = {    
			R.drawable.numpad_1, R.drawable.numpad_2,      
			R.drawable.numpad_3, R.drawable.numpad_4,     
			R.drawable.numpad_5, R.drawable.numpad_6,      
			R.drawable.numpad_7, R.drawable.numpad_8,      
			R.drawable.numpad_9, R.drawable.numpad_0,      
			R.drawable.numpad_clear, R.drawable.numpad_back,      
			R.drawable.numpad_00, R.drawable.numpad_000,      
			R.drawable.numpad_0000  
	};
	
	private int getCellHeightDP()    {
	    int height = mContext.getResources().getDisplayMetrics().heightPixels; 
//	    Log.d("height:",height+"");
		int cellHeight = height/10;  
//		Log.d("cellHeight:",cellHeight+"");
		return cellHeight;   
	}
	private int getCellWidthDP()    {
	    int width = mContext.getResources().getDisplayMetrics().widthPixels; 
//	    Log.d("width:",width+"");
		int cellWidth = width/15;  
//		Log.d("cellWidth:",cellWidth+"");
		return cellWidth;   
	}
}
